package com.hailiao.beidou.message.ui.page.status

import com.hailiao.beidou.message.R
import com.hailiao.beidou.message.bd.data.BDDeviceStatusData

/**
 * 设备状态
 * @Author d10ng
 * @Date 2023/11/17 17:03
 */
data class DeviceStatusData(
    // 图标ID
    val iconId: Int,
    // 标题
    val title: String,
    // 值
    val value: String,
)

fun BDDeviceStatusData.toDeviceStatusData() = DeviceStatusData(
    iconId = when(type) {
        BDDeviceStatusData.Type.CARD -> R.drawable.status_bd_card
        BDDeviceStatusData.Type.CARD_LEVEL -> R.drawable.status_bd_level
        BDDeviceStatusData.Type.CARD_FREQUENCY -> R.drawable.status_bd_frequency
        BDDeviceStatusData.Type.BATTERY -> R.drawable.status_battery
        BDDeviceStatusData.Type.LOCATION -> R.drawable.status_location
        BDDeviceStatusData.Type.ALTITUDE -> R.drawable.status_altitude
    },
    title = this.title,
    value = this.value
)

fun List<BDDeviceStatusData>.toDeviceStatusDataList() = this.map { it.toDeviceStatusData() }
